package com.wdb007.venus.svc.biz.book;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wdb007.venus.svc.dal.book.dao.BookShelfPushLogDAO;
import com.wdb007.venus.svc.dal.book.model.BookShelfPushLogDO;
import com.wdb007.venus.svc.facade.BookShelfPushService;
import com.wdb007.venus.svc.facade.book.model.BookShelfPushLogDTO;

@Service("bookShelfPushLogService")
public class BookShelfPushLogServiceImpl implements BookShelfPushService {

	@Autowired
	private BookShelfPushLogDAO bookShelfPushLogDAO;
	
	@Override
	public Long save(BookShelfPushLogDTO log) {
		
		BookShelfPushLogDO logDO = new BookShelfPushLogDO();
		logDO.setAction(log.getAction());
		logDO.setBookgridCode(log.getBookgridCode());
		logDO.setBookshelfCode(log.getBookshelfCode());
		logDO.setCreateTime(new Date());
		logDO.setOperStatus(0);
		bookShelfPushLogDAO.insert(logDO);
		return logDO.getId();
	}

	@Override
	public BookShelfPushLogDTO get(Long logId) {
		
		BookShelfPushLogDO result = bookShelfPushLogDAO.get(logId);
		if(null == result)
			return null;
		BookShelfPushLogDTO logDTO = new BookShelfPushLogDTO();
		logDTO.setAction(result.getAction());
		logDTO.setBookgridCode(result.getBookgridCode());
		logDTO.setBookshelfCode(result.getBookshelfCode());
		logDTO.setOperStatus(result.getOperStatus());
		
		return logDTO;
	}

	@Override
	public void update(Long logId) {
		BookShelfPushLogDO updateDO = new BookShelfPushLogDO();
		updateDO.setId(logId);
		updateDO.setOperStatus(1);
		updateDO.setModifyTime(new Date());
		
		bookShelfPushLogDAO.update(updateDO);
	}

}
